<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>jstree</title>
    <link rel="stylesheet" href="../static/bootstrap-3.3.7-dist/bootstrap-3.3.7-dist/css/bootstrap.min.css" />
    <link rel="stylesheet" href="../static/jstree/style.min.css" />
    <!-- <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.3/themes/default/style.min.css" /> -->

    <script src="../static/jquery-3.3.1.min.js"></script>
    <script src="../static/jstree/jstree.min.js"></script>
</head>

<body>
    <div id="menuTree"></div>
    <script>
        $(function () {
            var data = { "id": "-1", "text": "顶级节点", "state": { "opened": true, "disabled": true }, "checked": false, "attributes": null, "children": [{ "id": "97", "text": "图表管理", "state": { "selected": false, "checkbox_disabled": true }, "checked": false, "attributes": null, "children": [{ "id": "98", "text": "百度chart", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "97", "hasParent": true, "hasChildren": false }], "parentId": "0", "hasParent": false, "hasChildren": true }, { "id": "93", "text": "工作流程", "state": { "selected": false }, "checked": false, "attributes": null, "children": [{ "id": "101", "text": "待办任务", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "93", "hasParent": true, "hasChildren": false }, { "id": "96", "text": "流程管理", "state": { "selected": false }, "checked": false, "attributes": null, "children": [{ "id": "99", "text": "所有权限", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "96", "hasParent": true, "hasChildren": false }], "parentId": "93", "hasParent": true, "hasChildren": true }, { "id": "94", "text": "模型管理", "state": { "selected": false }, "checked": false, "attributes": null, "children": [{ "id": "95", "text": "全部权限", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "94", "hasParent": true, "hasChildren": false }], "parentId": "93", "hasParent": true, "hasChildren": true }], "parentId": "0", "hasParent": false, "hasChildren": true }, { "id": "91", "text": "系统监控", "state": { "selected": false }, "checked": false, "attributes": null, "children": [{ "id": "92", "text": "在线用户", "state": { "selected": false }, "checked": false, "attributes": null, "children": [], "parentId": "91", "hasParent": true, "hasChildren": false }, { "id": "57", "text": "运行监控", "state": { "selected": false }, "checked": false, "attributes": null, "children": [], "parentId": "91", "hasParent": true, "hasChildren": false }, { "id": "27", "text": "系统日志", "state": { "selected": false }, "checked": false, "attributes": null, "children": [{ "id": "30", "text": "清空", "state": { "selected": false }, "checked": false, "attributes": null, "children": [], "parentId": "27", "hasParent": true, "hasChildren": false }, { "id": "29", "text": "删除", "state": { "selected": false }, "checked": false, "attributes": null, "children": [], "parentId": "27", "hasParent": true, "hasChildren": false }, { "id": "28", "text": "刷新", "state": { "selected": false }, "checked": false, "attributes": null, "children": [], "parentId": "27", "hasParent": true, "hasChildren": false }], "parentId": "91", "hasParent": true, "hasChildren": true }], "parentId": "0", "hasParent": false, "hasChildren": true }, { "id": "84", "text": "办公管理", "state": { "selected": false }, "checked": false, "attributes": null, "children": [{ "id": "90", "text": "我的通知", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "84", "hasParent": true, "hasChildren": false }, { "id": "85", "text": "通知公告", "state": { "selected": false }, "checked": false, "attributes": null, "children": [{ "id": "89", "text": "批量删除", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "85", "hasParent": true, "hasChildren": false }, { "id": "88", "text": "删除", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "85", "hasParent": true, "hasChildren": false }, { "id": "87", "text": "编辑", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "85", "hasParent": true, "hasChildren": false }, { "id": "86", "text": "新增", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "85", "hasParent": true, "hasChildren": false }], "parentId": "84", "hasParent": true, "hasChildren": true }], "parentId": "0", "hasParent": false, "hasChildren": true }, { "id": "77", "text": "系统工具", "state": { "selected": false }, "checked": false, "attributes": null, "children": [{ "id": "104", "text": "swagger", "state": { "selected": false }, "checked": false, "attributes": null, "children": [], "parentId": "77", "hasParent": true, "hasChildren": false }, { "id": "72", "text": "计划任务", "state": { "selected": false }, "checked": false, "attributes": null, "children": [], "parentId": "77", "hasParent": true, "hasChildren": false }, { "id": "48", "text": "代码生成", "state": { "selected": false }, "checked": false, "attributes": null, "children": [], "parentId": "77", "hasParent": true, "hasChildren": false }], "parentId": "0", "hasParent": false, "hasChildren": true }, { "id": "49", "text": "博客管理", "state": { "selected": false }, "checked": false, "attributes": null, "children": [{ "id": "68", "text": "发布文章", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "49", "hasParent": true, "hasChildren": false }, { "id": "50", "text": "文章列表", "state": { "selected": false }, "checked": false, "attributes": null, "children": [{ "id": "60", "text": "批量删除", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "50", "hasParent": true, "hasChildren": false }, { "id": "59", "text": "删除", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "50", "hasParent": true, "hasChildren": false }, { "id": "58", "text": "编辑", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "50", "hasParent": true, "hasChildren": false }, { "id": "51", "text": "新增", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "50", "hasParent": true, "hasChildren": false }], "parentId": "49", "hasParent": true, "hasChildren": true }], "parentId": "0", "hasParent": false, "hasChildren": true }, { "id": "3", "text": "系统管理", "state": { "selected": false }, "checked": false, "attributes": null, "children": [{ "id": "73", "text": "部门管理", "state": { "selected": false }, "checked": false, "attributes": null, "children": [{ "id": "76", "text": "编辑", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "73", "hasParent": true, "hasChildren": false }, { "id": "75", "text": "刪除", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "73", "hasParent": true, "hasChildren": false }, { "id": "74", "text": "增加", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "73", "hasParent": true, "hasChildren": false }], "parentId": "3", "hasParent": true, "hasChildren": true }, { "id": "7", "text": "角色管理", "state": { "selected": false }, "checked": false, "attributes": null, "children": [{ "id": "62", "text": "批量删除", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "7", "hasParent": true, "hasChildren": false }, { "id": "56", "text": "删除", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "7", "hasParent": true, "hasChildren": false }, { "id": "55", "text": "编辑", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "7", "hasParent": true, "hasChildren": false }, { "id": "15", "text": "新增", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "7", "hasParent": true, "hasChildren": false }], "parentId": "3", "hasParent": true, "hasChildren": true }, { "id": "6", "text": "用户管理", "state": { "selected": false }, "checked": false, "attributes": null, "children": [{ "id": "105", "text": "rwr", "state": { "selected": false }, "checked": false, "attributes": null, "children": [], "parentId": "6", "hasParent": true, "hasChildren": false }, { "id": "26", "text": "重置密码", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "6", "hasParent": true, "hasChildren": false }, { "id": "25", "text": "停用", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "6", "hasParent": true, "hasChildren": false }, { "id": "24", "text": "批量删除", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "6", "hasParent": true, "hasChildren": false }, { "id": "14", "text": "删除", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "6", "hasParent": true, "hasChildren": false }, { "id": "13", "text": "编辑", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "6", "hasParent": true, "hasChildren": false }, { "id": "12", "text": "新增", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "6", "hasParent": true, "hasChildren": false }], "parentId": "3", "hasParent": true, "hasChildren": true }, { "id": "2", "text": "系统菜单", "state": { "selected": false }, "checked": false, "attributes": null, "children": [{ "id": "61", "text": "批量删除", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "2", "hasParent": true, "hasChildren": false }, { "id": "22", "text": "删除", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "2", "hasParent": true, "hasChildren": false }, { "id": "21", "text": "编辑", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "2", "hasParent": true, "hasChildren": false }, { "id": "20", "text": "新增", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "2", "hasParent": true, "hasChildren": false }], "parentId": "3", "hasParent": true, "hasChildren": true }], "parentId": "0", "hasParent": false, "hasChildren": true }, { "id": "1", "text": "基础管理", "state": { "selected": false }, "checked": false, "attributes": null, "children": [{ "id": "78", "text": "数据字典", "state": { "selected": false }, "checked": false, "attributes": null, "children": [{ "id": "83", "text": "批量删除", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "78", "hasParent": true, "hasChildren": false }, { "id": "81", "text": "删除", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "78", "hasParent": true, "hasChildren": false }, { "id": "80", "text": "编辑", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "78", "hasParent": true, "hasChildren": false }, { "id": "79", "text": "增加", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "78", "hasParent": true, "hasChildren": false }], "parentId": "1", "hasParent": true, "hasChildren": true }, { "id": "71", "text": "文件管理", "state": { "selected": true }, "checked": false, "attributes": null, "children": [], "parentId": "1", "hasParent": true, "hasChildren": false }], "parentId": "0", "hasParent": false, "hasChildren": true }], "parentId": "", "hasParent": false, "hasChildren": true }
            loadMenuTree(data);
        });

        function loadMenuTree(menuTree) {
            console.log(JSON.stringify(menuTree));
            $('#menuTree').jstree({
                "plugins": ["wholerow", "checkbox", "types"],
                'core': {
                    'data': menuTree
                },
                "checkbox": {
                },
                "types": {
                    "types": {
                        "default": { // Override default functionality 
                            "check_node": function (node) {
                                $(node).children('ul').children('li').children('a').children('.jstree-checkbox').click();
                                return true;
                            },
                            "uncheck_node": function (node) {
                                $(node).children('ul').children('li').children('a').children('.jstree-checkbox').click();
                                return true;
                            }
                        }
                    }
                }
            });
            $('#menuTree').jstree('open_all');
        }
    </script>
</body>

</html>